/*
 * ViewController
 * @description 本文件提供相册我的分组联系人操作界面的ViewController
 * @package
 * @author 		***
 * @copyright
 * @version 		1.0
 * @description 本文件提供相册我的分组联系人操作界面的ViewController
 */

#import "ViewController.h"
#import "UITableGridViewCell.h"
#import "UIImageButton.h"
#import "UIButton+WebCache.h"
#import "BanBu_NavButton.h"
#import "SD_New_groupViewController.h"
#import "AppCommunicationManager.h"
#import "AppDataManager.h"
#import "ExampleNestedTablesViewController.h"
#import "UIButton+WebCacheBack.h"
#import "BanBu_NavigationController.h"
#define kImageWidth  69 //UITableViewCell里面图片的宽度
#define kImageHeight  69 //UITableViewCell里面图片的高度

@interface ViewController ()

@end

@implementation ViewController
@synthesize dataArray = _dataArray;
-(void)dealloc
{
    [_dataArray release];
    _dataArray = nil;
    self.group_name = nil;
    self.superior = nil;
//    self.dataArray = Nil;
    [super dealloc];
}

- (void)viewWillDisappear:(BOOL)animated
{
    NSLog(@"%d",self.retainCount);
    [super viewWillDisappear:animated];
}
- (id)initWithPersonDataArray:(NSMutableArray *)dataAr;
{
    self = [super init];
    if (self) {
        _dataArray = [[NSMutableArray alloc]initWithCapacity:10];
        [_dataArray addObjectsFromArray:dataAr];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    _change = NO;
    self.view.backgroundColor = UIColorWithRGB(237, 239, 241, 1.0);
    deleteStatus = NO;
    self.title = self.groupname;
    self.view.backgroundColor = [UIColor whiteColor];
    self.image = [self cutCenterImage:[UIImage imageNamed:@"a1.jpg"]  size:CGSizeMake(74, 74)];
    CGSize mSize = [[UIScreen mainScreen] bounds].size;
    CGFloat screenWidth = mSize.width;
    CGFloat screenHeight = mSize.height;
    UITableView * btable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight-44) style:UITableViewStylePlain];
    self.tableView = btable;
    [btable release];
    [self.view addSubview:self.tableView];
    [self.tableView release];
    NSLog(@"%d",self.tableView.retainCount);
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
//    self.tableView.separatorColor  = [UIColor clearColor];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.backgroundColor = UIColorWithRGB(237, 239, 241, 1.0);
    self.tableView.showsVerticalScrollIndicator = NO;
    
    UIView * view = [[UIView alloc]init];
    view.frame = CGRectMake(0, 0, 320, 71);
    [self.view addSubview:view];
    
    UIImageView * grop_bg = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"album_inputBack.png"]];
    grop_bg.userInteractionEnabled = YES;
    grop_bg.frame = CGRectMake(10, 17, 300, 43);
    [view addSubview:grop_bg];
    
    UILabel * title = [[UILabel alloc]initWithFrame:CGRectMake(20, 27, 85, 20)];
    title.text = NSLocalizedString(@"album_groupname", 相册名称);
    [view addSubview:title];
    [title sizeToFit];
    title.font = [UIFont systemFontOfSize:16.0];
    self.group_name = [[UITextField alloc]initWithFrame:CGRectMake(22 + title.frame.size.width, 29, 285, 20)];
    self.group_name.clearButtonMode = UITextFieldViewModeWhileEditing;
    self.group_name.delegate = self;
    self.group_name.placeholder = NSLocalizedString(@"album_noTitle", 未命名);
    self.group_name.font = [UIFont systemFontOfSize:16.0];

    [self.group_name addTarget:self action:@selector(textFieldChangeEdit:) forControlEvents:UIControlEventEditingChanged];

    [view addSubview:self.group_name];
    [self.group_name release];
    self.tableView.tableHeaderView = view;
    [grop_bg release];
    
//    [self.view addSubview:self.group_name];

    if (MyAppDataManager.SelectGroupName) {
        self.group_name.text = MyAppDataManager.SelectGroupName;
    }
    self.navigationItem.leftBarButtonItem = [self createBackButton];
    UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
    footerView.backgroundColor = [UIColor clearColor];
    
    UIButton * del_btn = [UIButton buttonWithType:UIButtonTypeCustom];
    del_btn.frame = CGRectMake(10, 60, 300, 40);
    [del_btn setBackgroundImage:[UIImage imageNamed:@"ben_del.png"] forState:UIControlStateNormal];
    del_btn.tag =1;
    [del_btn addTarget:self action:@selector(btn_click:) forControlEvents:UIControlEventTouchUpInside];
    [del_btn setTitle:NSLocalizedString(@"Competence_Del", 删除分组) forState:UIControlStateNormal];
    [footerView addSubview:del_btn];

    UIButton * del_cpy = [UIButton buttonWithType:UIButtonTypeCustom];
    del_cpy.frame = CGRectMake(10, 10, 300, 40);
    del_cpy.tag =2;
    [del_cpy setBackgroundImage:[UIImage imageNamed:@"ben_cop.png"] forState:UIControlStateNormal];
    [del_cpy addTarget:self action:@selector(btn_click:) forControlEvents:UIControlEventTouchUpInside];
    [del_cpy setTitle:NSLocalizedString(@"Competence_Copy", 复制分组) forState:UIControlStateNormal];
    [footerView addSubview:del_cpy];
    self.tableView.tableFooterView = footerView;
}



-(void)deleteMember
{
    deleteStatus = !deleteStatus;
    [self.tableView reloadData];
}

#pragma mark UITable datasource and delegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    NSInteger num = _dataArray.count+2;
    return num%4?num/4+1:num/4;
}

//-(NSString*)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    return @"相册名称";
//}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *identifier = @"Cell";
    //自定义UITableGridViewCell，里面加了个NSArray用于放置里面的3个图片按钮
    UITableGridViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil)
    {
        cell = [[UITableGridViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    else
    {
        for(UIView *v in cell.contentView.subviews)
        {
            [v removeFromSuperview];
        }
    }
    cell.contentView.backgroundColor = UIColorWithRGB(237, 239, 241, 1.0);
    if (indexPath.section == 0){
    NSMutableArray *array = [NSMutableArray array];
    NSInteger cellNum = _dataArray.count+2-(indexPath.row*4);
    cellNum = cellNum>4?4:cellNum;
    for (int i=0; i<cellNum; i++) {
        //自定义继续UIButton的UIImageButton 里面只是加了2个row和column属性
        if(4*indexPath.row+i == _dataArray.count)
        {
            UIImageButton *button = [UIImageButton buttonWithType:UIButtonTypeCustom];
            button.bounds = CGRectMake(0, 0, kImageWidth, kImageHeight);
            button.center = CGPointMake((3 + i) * 5 + kImageWidth *( 0.5 + i) , 5 + kImageHeight * 0.5);
            [button setValue:[NSNumber numberWithInt:i] forKey:@"column"];
            [button addTarget:self action:@selector(popself) forControlEvents:UIControlEventTouchUpInside];
            [button setImage:[UIImage imageNamed:@"btn_add_member.png"] forState:UIControlStateNormal];
            [cell.contentView addSubview:button];
            [array addObject:button];
        }
        else if(4*indexPath.row+i == _dataArray.count+1)//减少成员控制
        {
            UIImageButton *button = [UIImageButton buttonWithType:UIButtonTypeCustom];
            button.bounds = CGRectMake(0, 0, kImageWidth, kImageHeight);
            button.center = CGPointMake((3 + i) * 5 + kImageWidth *( 0.5 + i) , 5 + kImageHeight * 0.5);
            [button setValue:[NSNumber numberWithInt:i] forKey:@"column"];
            [button addTarget:self action:@selector(deleteMember) forControlEvents:UIControlEventTouchUpInside];
            [button setImage:[UIImage imageNamed:@"btn_del_member.png"] forState:UIControlStateNormal];
            [cell.contentView addSubview:button];
            [array addObject:button];
        }
        else//头像控制
        {
            UIImageButton *button = [UIImageButton buttonWithType:UIButtonTypeCustom];
            button.bounds = CGRectMake(0, 0, kImageWidth, kImageHeight);
            button.center = CGPointMake((3 + i) * 5 + kImageWidth *( 0.5 + i) , 5 + kImageHeight * 0.5);
            button.layer.cornerRadius = 5.0;
            button.layer.masksToBounds = YES;
            [button setValue:[NSNumber numberWithInt:i] forKey:@"column"];
//            if([self.superior isEqual:@"group"])
//            {
//                [button.layer setCornerRadius:8.0];
//                button.clipsToBounds = YES;
//                if (!_change)
//                {
//                    [button setBackgroundImageWithURL:[NSURL URLWithString:[[[_dataArray objectAtIndex:4*indexPath.row+i] valueForKey:@"userinfor"] valueForKey:@"uface"]] placeholderImage:[UIImage imageNamed:@"default.png"] andType:0];
//                }
//                else
//                {
//                     [button setImageWithURL:[NSURL URLWithString:[[_dataArray objectAtIndex:4*indexPath.row+i] valueForKey:@"uface"]] placeholderImage:[UIImage imageNamed:@"default.png"] andType:0];
//                }
//                
////                [button setImageWithURL:[NSURL URLWithString:[[[_dataArray objectAtIndex:4*indexPath.row+i] valueForKey:@"userinfor"] valueForKey:@"uface"]] placeholderImage:[UIImage imageNamed:@"default.png"] andType:0];
//            }
//            else
//            {
//                [button setImageWithURL:[NSURL URLWithString:[[_dataArray objectAtIndex:4*indexPath.row+i] valueForKey:@"uface"]] placeholderImage:[UIImage imageNamed:@"default.png"] andType:0];
//            }
            
            BanBu_UserModel * userModel = [_dataArray objectAtIndex:4*indexPath.row+i];
            
            [button setBackgroundImageWithURL:[NSURL URLWithString:userModel.face_url] placeholderImage:[UIImage imageNamed:@"default.png"] andType:0];
            
//            if ([[_dataArray objectAtIndex:4*indexPath.row+i] valueForKey:@"uface"])
//            {
//                [button setImageWithURL:[NSURL URLWithString:[[_dataArray objectAtIndex:4*indexPath.row+i] valueForKey:@"uface"]] placeholderImage:[UIImage imageNamed:@"default.png"] andType:0];
//            }
//            else
//            {
//                BanBu_UserModel * userModel = [_dataArray objectAtIndex:4*indexPath.row+i];
//                
//                [button setBackgroundImageWithURL:[NSURL URLWithString:userModel.face_url] placeholderImage:[UIImage imageNamed:@"default.png"] andType:0];
//            }
            [cell.contentView addSubview:button];
            [array addObject:button];
            if(deleteStatus)
            {
                [button addTarget:self action:@selector(imageItemClick:) forControlEvents:UIControlEventTouchUpInside];
                UIImageView *delete = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
                delete.image = [UIImage imageNamed:@"btn_del_row.png"];
                [button addSubview:delete];
            }
        }
    }
    [cell setValue:array forKey:@"buttons"];
    //获取到里面的cell里面的3个图片按钮引用
    NSArray *imageButtons =cell.buttons;
    //设置UIImageButton里面的row属性
    [imageButtons setValue:[NSNumber numberWithInt:indexPath.row] forKey:@"row"];
//      [cell addSubview:view];
    }
    return cell;
}

#pragma mark 给section 添加圆角矩形背景
//- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
//    if ([cell respondsToSelector:@selector(tintColor)]) {
//        if (tableView == self.tableView) {
//            CGFloat cornerRadius = 5.f;
//            cell.backgroundColor = UIColor.clearColor;
//            CAShapeLayer *layer = [[CAShapeLayer alloc] init];
//            CGMutablePathRef pathRef = CGPathCreateMutable();
//            CGRect bounds = CGRectInset(cell.bounds, 10, 0);
//            BOOL addLine = NO;
//            // 判断是否需要上下圆角
//            if (indexPath.row == 0 && indexPath.row == [tableView numberOfRowsInSection:indexPath.section]-1) {
//                CGPathAddRoundedRect(pathRef, nil, bounds, cornerRadius, cornerRadius);
//            } else if (indexPath.row == 0) {
//                CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds));
//                CGPathAddArcToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMinY(bounds), CGRectGetMidX(bounds), CGRectGetMinY(bounds), cornerRadius);
//                CGPathAddArcToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMinY(bounds), CGRectGetMaxX(bounds), CGRectGetMidY(bounds), cornerRadius);
//                CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds));
//                addLine = YES;
//            } else if (indexPath.row == [tableView numberOfRowsInSection:indexPath.section]-1) {
//                CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMinY(bounds));
//                CGPathAddArcToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds), CGRectGetMidX(bounds), CGRectGetMaxY(bounds), cornerRadius);
//                CGPathAddArcToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds), CGRectGetMaxX(bounds), CGRectGetMidY(bounds), cornerRadius);
//                CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMinY(bounds));
//            } else {
//                CGPathAddRect(pathRef, nil, bounds);
//                addLine = YES;
//            } 
//            layer.path = pathRef;
//            CFRelease(pathRef);
//            // 內部颜色
//            layer.fillColor = UIColorToRGB(0xd1d1d1).CGColor;//UIColorFromRGB(0xd1d1d1).CGColor;
//            // 边框颜色
////            layer.strokeColor = [UIColor blackColor].CGColor;
//            UIView *testView = [[UIView alloc] initWithFrame:bounds];
//            [testView.layer insertSublayer:layer atIndex:0];
//            testView.backgroundColor = UIColor.clearColor;
//            cell.backgroundView = testView;
//        }
//    }
//}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return kImageHeight + 6;
}

//-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
//    [tableView deselectRowAtIndexPath:indexPath animated:YES];
//}

-(void)imageItemClick:(UIImageButton *)button{
    [self.dataArray removeObjectAtIndex:[self input:button.row+1 and:button.column+1]-1];
    [self.tableView reloadData];
}

#pragma mark 根据size截取图片中间矩形区域的图片 这里的size是正方形
-(UIImage *)cutCenterImage:(UIImage *)image size:(CGSize)size{
    CGSize imageSize = image.size;
    CGRect rect;
    //根据图片的大小计算出图片中间矩形区域的位置与大小
    if (imageSize.width > imageSize.height) {
        float leftMargin = (imageSize.width - imageSize.height) * 0.5;
        rect = CGRectMake(leftMargin, 0, imageSize.height, imageSize.height);
    }else{
        float topMargin = (imageSize.height - imageSize.width) * 0.5;
        rect = CGRectMake(0, topMargin, imageSize.width, imageSize.width);
    }
    CGImageRef imageRef = image.CGImage;
    //截取中间区域矩形图片
    CGImageRef imageRefRect = CGImageCreateWithImageInRect(imageRef, rect);
    UIImage *tmp = [[UIImage alloc] initWithCGImage:imageRefRect];
    CGImageRelease(imageRefRect);
    UIGraphicsBeginImageContext(size);
    CGRect rectDraw = CGRectMake(0, 0, size.width, size.height);
    [tmp drawInRect:rectDraw];
    // 从当前context中创建一个改变大小后的图片
    tmp = UIGraphicsGetImageFromCurrentImageContext();
    // 使当前的context出堆栈
    UIGraphicsEndImageContext();
    return tmp;
}

- (UIBarButtonItem*)createBackButton
{
    BanBu_NavButton *btn_return=[[BanBu_NavButton alloc] initWithButtonType:UIButtonCreatTypeBack];
    btn_return.position = ButtonPositionLeft;
    [btn_return addTarget:self action:@selector(pop) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *bar_itemreturn=[[[UIBarButtonItem alloc] initWithCustomView:btn_return] autorelease];
    _saveBu = [UIButton buttonWithType:UIButtonTypeCustom];
    [_saveBu setTitle:NSLocalizedString(@"saveButton", 保存) forState:UIControlStateNormal];
    [_saveBu setFrame:CGRectMake(0, 0, 60, 35)];
    if (self.group_name.text.length > 0)
    {
        [_saveBu setTitleColor:UIColorWithRGB(255, 255, 255, 1.0) forState:UIControlStateNormal];
        _saveBu.userInteractionEnabled = YES;
    }
    else
    {
        [_saveBu setTitleColor:UIColorWithRGB(255, 255, 255, 0.5) forState:UIControlStateNormal];
        _saveBu.userInteractionEnabled = NO;
    }
    
    _saveBu.titleLabel.font = [UIFont systemFontOfSize:16.0];
    [_saveBu addTarget:self action:@selector(SubmitData) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem * saveItem = [[UIBarButtonItem alloc]initWithCustomView:_saveBu];
    self.navigationItem.rightBarButtonItem = saveItem;
    return bar_itemreturn;
}

#pragma mark - 提交分组信息
-(void)SubmitData//提交分组信息
{
//    __block  NSMutableArray *muArr = [NSMutableArray arrayWithCapacity:1];
//    [self.dataArray enumerateObjectsUsingBlock:^(NSDictionary * objDic, NSUInteger idx, BOOL *stop) {
//        NSString *id_ = [objDic objectForKey:@"userid"];
//        [muArr addObject:id_];
//    }];
//    NSString * string =@"";
//    for (int i=0; i<muArr.count; i++) {
//        string = [NSString stringWithFormat:@"%@,%@",string,[muArr objectAtIndex:i]];
//    }
    NSString * string =@"";
    for (BanBu_UserModel * userModel in self.dataArray)
    {
        string = [NSString stringWithFormat:@"%@,%@",string,userModel.user_id];
    }
    NSString *uidlist = (string.length > 1)?[string substringFromIndex:1]:string;
    
    if (self.group_name.text.length>0) {
        [AppComManager getBanBuData:BanBu_Set_Friend_byGroup par:[NSDictionary dictionaryWithObjectsAndKeys:self.group_name.text,@"groupname",uidlist,@"uidlist",nil] delegate:self];
    }
    else 
    {
        UIAlertView * aler = [[UIAlertView alloc]initWithTitle:NSLocalizedString(@"noticeNotice", nil) message:NSLocalizedString(@"inputAlbumNameLimit", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"确定", nil) otherButtonTitles:nil, nil];
        [aler show];
    }
}


- (void)banbuRequestDidFinished:(NSDictionary *)resDic error:(NSError *)error
{
    NSLog(@"%@",resDic);
    if(error)
    {
        
    }
    else
    {
        if([AppComManager respondsDic:resDic isFunctionData:BanBu_Set_Friend_byGroup])
        {
            if([[resDic valueForKey:@"ok"] boolValue])//创建分组成功
            {
                [[NSNotificationCenter defaultCenter] postNotificationName:@"DismissSelectUser" object:nil];
                NSDictionary * createDict = [NSDictionary dictionaryWithObjectsAndKeys:@"create",@"action",self.group_name.text,@"title", nil];
                [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshView" object:createDict];
                [self dismissViewControllerAnimated:YES completion:^{
                }];
                [self pop];
            }
        }
        if([AppComManager respondsDic:resDic isFunctionData:BanBu_Del_Friendgroup_Byuser])
        {
            if([[resDic valueForKey:@"ok"] boolValue])//删除分组成功
            {
                NSDictionary * deleteDict = [NSDictionary dictionaryWithObjectsAndKeys:@"delete",@"action",MyAppDataManager.SelectGroupName,@"title", nil];
                [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshView" object:deleteDict];
                [self.navigationController popViewControllerAnimated:YES];
            }
        }
    }
}
#pragma mark - 删除分组 复制分组
-(void)btn_click:(UIButton*)btn
{
    if (btn.tag == 1)
    {
        NSLog(@"%@",self.groupname);
        UIAlertView * alret = [[UIAlertView alloc]initWithTitle:nil message:NSLocalizedString(@"deleteGroup", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"cancelNotice", nil) otherButtonTitles:NSLocalizedString(@"confirmNotice", nil), nil];
        [alret show];
        [alret release];
    }
    else
    {
        self.group_name.text = [NSString stringWithFormat:@"%@%@",self.group_name.text,@"1"];
    }
    
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    switch (buttonIndex)
    {
        case 0:
            break;
        case 1:
            [AppComManager getBanBuData:BanBu_Del_Friendgroup_Byuser par:[NSDictionary dictionaryWithObjectsAndKeys:self.groupname,@"groupname",nil] delegate:self];
            [self dismissViewControllerAnimated:YES completion:^{
            }];
            break;
        default:
            break;
    }
}
//输出点击位置
-(int)input:(int)line and:(int)column
{
    int selectdat = ((line-1)*4)+column;
    return selectdat;
}

-(void)pop
{
    if ([self.superior isEqual: @"group"]) {
        [self.navigationController popViewControllerAnimated:YES];
    }
    else
    {
        [self dismissViewControllerAnimated:YES completion:^{
        }];
    }
}

-(void)popself
{
    if ([self.superior isEqual: @"group"])
    {
        ExampleNestedTablesViewController * evc = [[ExampleNestedTablesViewController alloc]initWithChoosedPeople:self.dataArray];
        __block NSMutableArray * bdateArray = _dataArray;
        __block UITableView * btable = self.tableView;
        [evc setChangeGroupCallBack:^(NSArray *selectedArr)
        {
            [bdateArray removeAllObjects];
            [bdateArray addObjectsFromArray:selectedArr];
            [btable reloadData];
        }];
        BanBu_NavigationController *nav = [[BanBu_NavigationController alloc] initWithRootViewController:evc];
        [self presentModalViewController:nav animated:YES];
        [evc release];
        evc = nil;
        [nav release];
        nav = nil;
    }
    else
    {
        [self dismissViewControllerAnimated:YES completion:^{
        }];
    }
}

#pragma mark UITextField Delegate
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [self.group_name resignFirstResponder];
    return YES;
}

//检测textfield的text变化，当拼音转化成汉字的时候可以检测到
- (void)textFieldChangeEdit:(UITextField *)sender
{
    if (sender.text.length <= 0)
    {
        _saveBu.userInteractionEnabled = NO;
        [_saveBu setTitleColor:UIColorWithRGB(255, 255, 255, 0.5) forState:UIControlStateNormal];
    }
    else
    {
        _saveBu.userInteractionEnabled = YES;
        [_saveBu setTitleColor:UIColorWithRGB(255, 255, 255, 1) forState:UIControlStateNormal];
        
    }
}



@end
